<%@ page language="java" import="java.util.*,com.css.vo.*" pageEncoding="UTF-8"%>
<%@ page import="com.css.dao.*,com.css.dao.impl.*"%>
<%@ page import="com.css.dao.*,com.css.action.*"%>
<%@ page import="com.css.dao.*,com.css.service.*"%>
<%@ page import="org.springframework.context.*,org.springframework.context.support.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.DecimalFormat" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>销售信息管理</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>
  <header>
  	<h1>销售信息管理</h1>
    <nav>
      <ul>
        <li><a href="index.jsp">首页</a></li>
        <li><a href="getList.action">系统管理</a></li>
        <li><a href="customer-management.jsp">客户信息管理</a></li>
        <li><a href="car-management.jsp">汽车信息管理</a></li>
        <li><a href="employee-management.jsp">员工信息管理</a></li>
        <li><a href="sales-management.jsp">销售信息管理</a></li>
      </ul>
    </nav>
  </header>

   <div class="content">
    <h2>本月销冠列表</h2> 
    <table>
      <thead>
        <tr>
          <th>名次</th>
          <th>员工姓名</th>
          <th>销售金额(元)</th>
          <th>售出汽车(辆)</th>
        </tr>
      </thead>
      <tbody>
        <% 
          // 获取销售数据
          ApplicationContext myaApplicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
  		  ISaleService saleService = (ISaleService) myaApplicationContext.getBean("saleService");
  		  
  		  List<SaleTop> saleTopList = saleService.getSaleTopList();
  		  
          if (saleTopList != null && !saleTopList.isEmpty()) {
          	  int i = 1;
              for (SaleTop sale : saleTopList) {
              DecimalFormat df = new DecimalFormat("#,###.00");
        	  String totalSaleStr = df.format(sale.getTotalSale());
              
        %>
        <tr>
          <td><%= "NO." + i %></td>
          <td><%= sale.getEmployeeName() %></td>
          <td><%= totalSaleStr %></td>
          <td><%= sale.getCountSale() %></td> 
        </tr>
        <% 
        		i++;
              }
              i = 1;
          } else {
        %>
        <tr>
          <td colspan="5" style="text-align: center;">暂无数据</td>
        </tr>
        <% } %>
      </tbody>
    </table>
    
	<table width="450" align="center" border="0">
	<!-- 分页 -->

    </table>

  </div>
</body>
</html>
